﻿using OrmTest;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OrmTest
{
    public class Demo_GetTableList
    {
        public static void Init()
        {
            Console.WriteLine("#### GetTableInfoList Start ####");
            SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
            {
                DbType = DbType.Dm,
                ConnectionString = Config.ConnectionString,
                InitKeyType = InitKeyType.Attribute,
                IsAutoCloseConnection = true,
                AopEvents = new AopEvents()
                {
                    OnLogExecuting = (sql, pars) =>
                    {
                        Console.WriteLine(sql);
                        foreach (var item in pars)
                        {
                            Console.WriteLine(item.ParameterName + ":" + item.Value);
                        }
                    }
                }
            });
            //USER_TAB_COMMENTS去重复，是因为不同模式下可能存在同名的表
            var list = db.DbMaintenance.GetTableInfoList(false);
            Console.WriteLine("#### GetTableInfoList End ####");
        }
    }
}
